
<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/shops.css" rel="stylesheet" type="text/css"/>
</block>
<block name="header">
<include file="_nav"/>
</block>
<block name="body">

<div class="container">

<div class="row shop">
    <div class="col-xs-12   clearfix">
        <div class="col-xs-12 common_block_border pad_15">
            <div class="clearfix">
                <h2 class="title_content">{:L('_PRODUCT_NEW_ADDED_')}</h2>
                <volist name="contents_new" id="vo">
                    <div class="col-xs-3 goods">
                        <div class="item_goods position_re">
                            <i class="ico_new"></i>
                            <dl>
                                <dt>
                                    <a href="{:U('Shop/Index/goodsDetail',array('id'=>$vo['id']))}">
                                        <img style="width: 222px;height: 222px" src="{$vo.goods_ico|getThumbImageById=222,222}">
                                    </a>
                                </dt>
                                <dd>
                                    <div class="left" style="width: 140px">
                                        <a class="text-more color_33"
                                           href="{:U('Shop/Index/goodsDetail',array('id'=>$vo['id']))}"
                                           style="width: 100%;">
                                            <font title="{$vo.goods_name|op_t}">{$vo.goods_name}</font>
                                        </a>
                                    </div>
                                    <div class="right" style="color: #d61f39;"><a><font title="{:L('_NEED_')}{$money_type.title}"><i
                                            class="ico_to_money"></i>&nbsp;{$vo.money_need} {$money_type.unit}</font></a></div>
                                    <div class="clearfix"></div>
                                </dd>
                                <dd class="color_84 font_s_14">
                                    <div class="left">{:L('_STOCK_')}{:L('_COLON_')}{$vo.goods_num}</div>
                                    <php>
                                        $class='';
                                        if(is_login()){
                                        if($my_money>=$vo['money_need']){
                                        $class='open-popup-link';
                                        }else{
                                        $class='money_not_enough ';
                                        }
                                        }
                                    </php>
                                    <div class="right">
                                        <a href="#frm-post-popup" class="{$class} btn exchange_goods"
                                           style="border: 1px solid #E0DBDB"
                                           goods_id="{$vo['id']}">{:L('_EXCHANGE_')}</a>
                                    </div>
                                </dd>
                                <div class="clearfix"></div>
                            </dl>
                        </div>
                    </div>
                </volist>
                <if condition="count($contents_new) eq 0">
                    <div style="font-size:3em;padding:2em 0;color: #ccc;text-align: center">{:L('_TIP_NEW_PRODUCT_NONE_')}</div>
                </if>
            </div>
          <div class="clearfix">
              <h2 class="title_content">{:L('_PRODUCT_HOTTEST_')}</h2>
              <volist name="contents_hot" id="vo">
                  <div class="col-xs-3 goods">
                      <div class="item_goods position_re">
                          <i class="ico_hot"></i>
                          <dl>
                              <dt>
                                  <a href="{:U('Shop/Index/goodsDetail',array('id'=>$vo['id']))}">
                                      <img class="img-responsive" src="{$vo.goods_ico|getThumbImageById=222,222}">
                                  </a>
                              </dt>
                              <dd>
                                  <div class="left" style="width: 140px">
                                      <a class="text-more"
                                         href="{:U('Shop/Index/goodsDetail',array('id'=>$vo['id']))}"
                                         style="width: 100%;">
                                          <font title="{$vo.goods_name|op_t}">{$vo.goods_name}</font>
                                      </a>
                                  </div>
                                  <div class="right" style="color: #d61f39;"><a><font title="{:L('_NEED_')}{$money_type.title}"><i
                                          class="ico_to_money"></i>&nbsp;{$vo.money_need} {$money_type.unit}</font></a></div>
                                  <div class="clearfix"></div>
                              </dd>
                              <dd class="color_84 clearfix">
                                  <div class="left">{:L('_STOCK_')}{:L('_COLON_')}{$vo.goods_num}</div>
                                  <php>
                                      $class='';
                                      if(is_login()){
                                      if($my_money>=$vo['money_need']){
                                      $class='open-popup-link';
                                      }else{
                                      $class='money_not_enough ';
                                      }
                                      }
                                  </php>
                                  <div class="right">
                                      <a href="#frm-post-popup" class="{$class} btn exchange_goods"
                                         style="border: 1px solid #E0DBDB"
                                         goods_id="{$vo['id']}">{:L('_EXCHANGE_')}</a>
                                  </div>
                              </dd>
                          </dl>
                      </div>
                  </div>
              </volist>
              <if condition="count($contents_hot) eq 0">
                  <div style="font-size:3em;padding:2em 0;color: #ccc;text-align: center">{:L('_TIP_HOT_PRODUCT_NONE_')}
                  </div>
              </if>
          </div>
          </div>
        </div>
        <div class="col-xs-12  pad_15">

    </div>
</div>
<if condition="is_login()">
    <!-- Modal -->
    <div id="frm-post-popup" class="white-popup mfp-hide" style="max-width: 500px;">
        <h2>{:L('_H_RECEIVING_INFO_')}<span style="font-size: 12px;color: #BEBEBE;">{:L('_H_RECEIVING_INFO_VICE_')}</span></h2>

        <div class="aline" style="margin-bottom: 10px"></div>
        <div class="row">
            <form class="form-horizontal  ajax-form" role="form" action="{:U('Shop/Index/goodsBuy')}" method="post">
                <input type="hidden" id="goods_id" name="id" value="">
                <input type="hidden" name="address_id" value="{$shop_address['id']}">

                <div class="form-group">
                    <label for="name" class="col-xs-2 control-label" style="width: 20%">{:L('_NAME_')}</label>

                    <div class="col-xs-10" style="width: 60%">
                        <input id="name" name="name" type="text" class="form-control"
                               value="{$shop_address['name']}" placeholder="{:L('_NAME_')}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="address" class="col-xs-2 control-label" style="width: 20%">{:L('_RECEIVING_ADDRESS_')}</label>

                    <div class="col-xs-10" style="width: 60%">
                        <textarea id="address" name="address" class="form-control" placeholder="{:L('_RECEIVING_ADDRESS_')}"
                                  style="max-width: 310px">{$shop_address['address']}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="zipcode" class="col-xs-2 control-label" style="width: 20%">{:L('_POST_CODE_')}</label>

                    <div class="col-xs-10" style="width: 60%">
                        <input id="zipcode" name="zipcode" type="text" class="form-control"
                               value="{$shop_address['zipcode']}" placeholder="{:L('_POST_CODE_')}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="phone" class="col-xs-2 control-label" style="width: 20%">{:L('_PHONE_NUMBER_')}</label>

                    <div class="col-xs-10" style="width: 60%">
                        <input id="phone" name="phone" type="text" class="form-control"
                               value="{$shop_address['phone']}" placeholder="{:L('_PHONE_NUMBER_')}"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-xs-10">
                        <button type="submit" class="btn btn-primary ">{:L('_SUBMIT_')}</button>
                    </div>
                </div>
            </form>
        </div>


    </div>
    <!-- /.modal -->
</if>
</div>
<input type="hidden" id="money_name" value="{$money_type.title}"/>
</block>

<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script>
        var money_name = $('#money_name').val().trim();
        $(function () {
            $('.exchange_goods').click(function () {
                if (MID == 0) {
                    toast.info("{:L('_TOAST_TIP_LOG_')}{:L('_EXCLAMATION_')}", "{:L('_TOAST_TIP_PROMPT_')}");
                    return false;
                }
                var goods_id = this.getAttribute('goods_id');
                $('#goods_id').val(goods_id);
            });
            if (MID != 0) {
                $('.money_not_enough').click(function () {
                    toast.info("{:L('_TOAST_TIP_LACK_')}" + money_name + "{:L('_TOAST_TIP_LACK2_')}{:L('_EXCLAMATION_')}", "{:L('_TOAST_TIP_PROMPT_')}");
                    return false;
                });
                $('.open-popup-link').magnificPopup({
                    type: 'inline',
                    midClick: true, // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
                    closeOnBgClick: false
                });
            }
            $('.item_goods').mouseover(function () {
                $(this).addClass('item_goods_box_shadow');
            });
            $('.item_goods').mouseleave(function () {
                $(this).removeClass('item_goods_box_shadow');
            });
        })
    </script>
</block>
